package com.zx._12_算法.剑指offer._2022;

import com.zx.common.model.ListNode;

public class 链表中倒数第k个结点 {

    public static void main(final String[] args) {
        final ListNode nodes = ListNode.getNodes(1, 2, 3, 4, 5, 6);
        final int k = 1;

        ListNode first = nodes;
        for (int i = 0; i < k; i++) {
            first = first.next;
        }

        ListNode second = nodes;
        while (true) {
            if (first == null) {
                break;
            }

            first = first.next;
            second = second.next;
        }
        System.out.println(second);
    }
}
